package com.c.ctgproject.wiget.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import com.c.ctgproject.R
import com.c.ctgproject.databinding.CommonDialogBinding

class CommonAlertDialog(context: Context,private val  msg: String,private val  block: () -> Unit) : Dialog(context, R.style.common_dialog) {

    private var _binding: CommonDialogBinding? = null
    private val mBinding: CommonDialogBinding get() = _binding!!

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        _binding = CommonDialogBinding.inflate(layoutInflater)
        setContentView(mBinding.root)
        mBinding.mTitleTV.text = msg
        mBinding.mCancelTV.setOnClickListener {
            this.cancel()
        }
        mBinding.mConfirmTV.setOnClickListener {
            block()
            this.cancel()
        }
    }

    override fun onDetachedFromWindow() {
        super.onDetachedFromWindow()
        _binding = null
    }
}